#include <windows.h>
#include <iostream>

typedef int (*A1Func)(char*, int);
typedef int (*A2Func)(char*);

int main() {
    HINSTANCE hinstLib = LoadLibrary(TEXT("A.dll"));
    if (hinstLib != NULL) {
        A1Func A1 = (A1Func)GetProcAddress(hinstLib, "A1");
        A2Func A2 = (A2Func)GetProcAddress(hinstLib, "A2");

        if (A1 != NULL && A2 != NULL) {
            char buff1[6] = "Hello";
            std::cout << "E called A1 with: " << buff1 << std::endl;
            A1(buff1, 5);
            char*  buff2 = new char[6];
            strcpy(buff2, "I'm E");
            std::cout << "E called A2 with: " << buff2 << std::endl;
            A2(buff2);
            std::cout << "E called A2 got: " << buff2 << std::endl;
            delete[] buff2;
        } else {
            std::cerr << "Failed to load A1 or A2" << std::endl;
        }

        FreeLibrary(hinstLib);
    } else {
        std::cerr << "Failed to load A.dll" << std::endl;
    }

    return 0;
}